﻿using System.Windows;
using Box2DX.Collision;
using Box2DX.Common;
using Box2DX.Dynamics;

namespace Expression.Samples.Physics {

	public class BodyParameters {
		public bool IsStatic { get; set; }
		public double Density { get; set; }
		public double Friction { get; set; }
		public double Restitution { get; set; }
		public object UserData { get; set; }
		public Vector InitialVelocity { get; set; }
		public double InitialRotationalVelocity { get; set; }
		public bool CanRotate { get; set; }
		public double LinearDamping { get; set; }
		public double AngularDamping { get; set; }

		public BodyParameters() {
			this.IsStatic = false;
			this.Density = 1;
			this.Friction = 0.6;
			this.Restitution = 0.1;
			this.LinearDamping = 5;
			this.AngularDamping = 5;
			this.CanRotate = false;
		}

		public void SetParameters(ShapeDef shapeDef) {
			shapeDef.Density = this.IsStatic ? 0 : (float)this.Density;
			shapeDef.Friction = (float)this.Friction;
			shapeDef.Restitution = (float)this.Restitution;
			shapeDef.UserData = this.UserData;
		}

		public void SetParameters(BodyDef bodyDef) {
			bodyDef.LinearDamping = (float)this.LinearDamping;
			bodyDef.AngularDamping = (float)this.AngularDamping;
		}

		public void SetParameters(Body body) {
			body.LinearVelocity = new Vector2((float)this.InitialVelocity.X, (float)this.InitialVelocity.Y);
			body.AngularVelocity = (float)this.InitialRotationalVelocity;
			body.UserData = this.UserData;
			
		}
	}
}
